<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of class
 *
 * @author NTC
 */
class Datababase {
    var $con;
    function __construct(){
            try{
                $this->con = mysql_connect(DB_HOST, DB_USER, DB_PASS);
            }catch(Exception $e){
                throw $e;
            }
            mysql_set_charset("utf8");
            mysql_select_db("group2", $this->con);
    }

    function query($sql, $fetchArray = true){
        
        $rs = mysql_query($sql) or die(mysql_error());
        $res = $fetchArray?$this->fetchArray($rs):$rs;
        return $res;

    }

    function fetchArray($rs){
        $aReturn = array();
        while ($row = mysql_fetch_array($rs)) {
            $aReturn[] = $row;
        }
        return $aReturn;
    }




    function  __destruct() {
        mysql_close();
    }
}
?>
